/**
 * @param {number[][]} brackets
 * @param {number} income
 * @return {number}
 */
 var calculateTax = function(brackets, income) {
  let ans = 0
  if(income > brackets[0][0]) {
    ans += brackets[0][1] * brackets[0][0] * 0.01
    income -= brackets[0][0]
  } else {
    return income * brackets[0][1] * 0.01
  }
  for(let i = 1; i<brackets.length; i++) {
    if(income > brackets[i][0] - brackets[i-1][0]) {
      ans += (brackets[i][0] - brackets[i-1][0]) * brackets[i][1] * 0.01
      income -= brackets[i][0] - brackets[i-1][0]
    } else {
      ans += income * brackets[i][1] * 0.01
      break
    }
  }
  return ans
};